{extend name="admin/base_pop" /}
{block name="resources"}
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>
<style>
.count-table .title{
	font-weight:bold;
	margin-bottom:10px;
}
.count-table span{
	display:inline-block;
	width:16%;
}
.table-class{border-top: 1px solid #E1E6F0}
</style>
{/block}
{block name="main"}
<div class="space-10"></div>
<table class="table-class count-table" >
	<tbody>
		<tr>
			<td width="1%"></td>
			<td>
				<div class="title">会员信息</div>
				<span>会员账号：{$member_detail['user_info']['user_name']}</span>
				<span>会员等级：{$member_detail['level_name']}</span>
			</td>
		</tr>
		<tr>
			<td width="1%"></td>
			<td>
				<div class="title">账户信息</div>
				<span>当前余额：{$member_detail['balance']}</span>
				<span>当前兑换银币：{$member_detail['point']}</span>
				<span>当前锁定银币：{$member_detail['salary']}</span>
				<span>当前订单金额：{$member_detail['rank_point']}</span>
			</td>
		</tr>
	</tbody>
</table>
<table class="mytable">
	<tr>
		<td style="text-align: left">总金额：<span id="account">0</span></td>
		<td width="50%">
			<span>发生时间：</span>
			<input type="text" id='startDate' placeholder="请选择开始日期" class="input-medium input-common  middle" onclick="WdatePicker()"/>
			&nbsp;-&nbsp;
			<input type="text" id='endDate' placeholder="请选择结束日期" class="input-medium input-common  middle" onclick="WdatePicker()" />
			<!-- 更多搜索按钮 -->
			<button class="btn-common-white more-search"><i class="fa fa-angle-down"></i></button>
			<button type="button" onclick="searchData()" value="搜索" class="btn-common" >搜索</button>
			<!-- 更多搜索下拉框 -->
			<div class="more-search-container">
				<dl>
					<dt>相关描述：</dt>
					<dd>
						<input type="text" id='search_text' placeholder="请输入相关描述" class="input-common  middle" />
					</dd>
				</dl>
				<dl>
					<dt>账户类型：</dt>
					<dd>
						<select id="account_type" class="select-common  middle">
							<option value="">全部</option>
							{volist name="account_type_list" id="val"}
							<option value="{$val.type_id}">{$val.type_name}</option>
							{/volist}
						</select>
					</dd>
				</dl>
				<dl>
					<dt>发生方式：</dt>
					<dd>
						<select id="from_type" class="select-common  middle">
							<option value="">全部</option>
							{volist name="from_type_list" id="val"}
							<option value="{$val.type_id}">{$val.type_name}</option>
							{/volist}
						</select>
					</dd>
				</dl>
				<dl>
					<dt></dt>
					<dd><button onclick="searchData()" class="btn-common">搜索</button></dd>
				</dl>
			</div>
		</td>
	</tr>
</table>
<table class="table-class" >

	<thead>
		<tr align="center">
			<th ><i class="checkbox-common"><input type="checkbox" ></i></th>
			<th align="left">会员昵称</th>
			<th align="left">账户类型</th>
			<th align="left">产生方式</th>
			<th align="left">描述</th>
			<th align="right">数量</th>
			<th align="center">释放完成</th>
			<th align="center">是否锁定</th>
			<th>时间</th>
			<th align="center">操作</th>
		</tr>
	</thead>
	<tbody id="my-table"></tbody>
</table>
<input type="hidden" id="member_id" value="{$member_id}"/>
{/block}
{block name="script"}
<script type="text/javascript">
function LoadingInfo(page_index) {

	var search_text = $("#search_text").val();
	var start_date = $("#startDate").val();
	var end_date = $("#endDate").val();
	var member_id = $("#member_id").val();
	var account_type = $("#account_type").val();
	var from_type = $("#from_type").val();

	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/member/memberReleaseList')}",
		data : {
			"page_index" : page_index,
			"page_size" : $("#showNumber").val(),
			"search_text":search_text,
			"member_id":member_id,
			"start_date":start_date,
			"end_date":end_date,
			"account_type" : account_type,
			"from_type" : from_type
		},
		success : function(data) {
			//console.log(data);
			var total_account = data.total_account;
			$("#account").html(total_account);
			if (data["data"].length > 0) {
				$("#my-table").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td><i class="checkbox-common"><input name="sub" type="checkbox" value="'+ data["data"][i]["id"] +'" ></i></td>';
					html += '<td align="left">'+data["data"][i]["nick_name"]+'</td>';
					html += '<td align="left">'+data["data"][i]["account_type_name"]+'</td>';
					html += '<td align="left">'+data["data"][i]["type_name"]+'</td>';
					html += '<td align="left">'+ data["data"][i]["text"] +'</td>';
					html += '<td align="right">'+ data["data"][i]["number"] +'<span class="row-30"></td>';

					html += '<td align="center">';

					if(data["data"][i]["release_ok"]){
						html += '已释放完成';
					}

					html += '</td>';
					html += '<td align="center">';

					if(data["data"][i]["lock"]){
						html += '<a onclick="unlock_record('+ data["data"][i]["id"]+')">锁定，点击解锁</a>';
					}else {
						html += '正常';
					}

					html += '</td>';

					html += '<td align="center">'+ timeStampTurnTime(data["data"][i]["create_time"]) +'</td>';
					html += '<td align="center">';

					if(data["data"][i]["lock"]){
						html += '<a onclick="deleteRec('+ data["data"][i]["id"]+')">删除</a>';
					}

					html += '</td>';

					html += '</tr>';
					html += '<input type="hidden" id="member_id" value="{$member_id}"/>';
					$("#my-table").append(html);
				}
			} else {
				var html = '<tr align="center"><td colspan="8">暂无符合条件的数据记录</td></tr>';
				$("#my-table").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

function searchData(){
	LoadingInfo(1);
}

//点击显示更多搜索
$(".more-search").click(function(){
	$(".more-search-container").slideToggle();
})




let flag = false;
function unlock_record(id){
	$( "#dialog" ).dialog({
		buttons: {
			"确定": function() {

				if(flag == true){
					$(this).dialog('close');
					return;
				}
				flag = true
				$.ajax({
					type : "post",
					url : "{:__URL('ADMIN_MAIN/Member/unlockRecord')}",
					data : { "id" : id },
					dataType : "json",
					success : function(data) {
						if(data["code"] > 0 ){
							LoadingInfo(getCurrentIndex(id,'#productTbody'));
							showTip(data["message"],'success');
							$("#chek_all").prop("checked", false);
						}else{
							showTip(data["message"],'error');
						}
					}
				});
				flag = false
				$(this).dialog('close');
			},
			"取消,#e57373": function() {
				$(this).dialog('close');
			},
		},
		contentText:"<span style='color: green;font-size: x-large'>款已收到，确定解锁订单吗？</span>",
	});
}


function deleteRec(id) {
	$( "#dialog" ).dialog({
		buttons: {
			"确定": function() {
				$.ajax({
					type : "post",
					url : "{:__URL('ADMIN_MAIN/Member/deleteAccountRec')}",
					data : { "id" : id },
					dataType : "json",
					success : function(data) {
						if(data["code"] > 0 ){
							LoadingInfo(getCurrentIndex(id,'#productTbody'));
							showTip(data["message"],'success');
							$("#chek_all").prop("checked", false);
						}else{
							showTip(data["message"],'error');
						}
					}
				});
				$(this).dialog('close');
			},
			"取消,#e57373": function() {
				$(this).dialog('close');
			},
		},
		contentText:"<span style='color: red;font-size: x-large'>慎重,确定要删除这条记录吗？</span>",
	});
}
</script>
{/block}
